import cloud from '@tbmp/mp-cloud-sdk';
cloud.init({
  env: 'online'
});
App({
  cloud,
  globalData: {
    shop_id: ''
  },
  onLaunch(options) {
    my.authorize({
      scopes: '*',
      success(res) {
        console.log(res)
      }
    })
    this.loadShop();
  },
  onShow(options) {
  },
  async loadShop() {
    const cloud = this.cloud;
    try {
      const res = await cloud.topApi.invoke({
        api: 'taobao.shop.seller.get',
        authScope: '*',
        data: { fields: 'sid,title,pic_path' }
      });
      this.globalData.shop_id = res.shop.sid;
      console.log(getApp().globalData)

    } catch (e) {
      my.alert({ content: 'error ' + e.message })
    }
  },
});
